#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
// int a[MAXN];
int odd[MAXN];
int even[MAXN];

int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int n;
	int t;
	cin >> t;
	while(t--){
		int a;
		cin >> n;
		int j = 0,k = 0;
		for(int i = 0;i < n;i++){
			cin >> a;
			if(a % 2 != 0){
				odd[j++] = a;
			}else{
				even[k++] = a;
			}
		}
		int flag = 0;
		for(int i = 0;i < j - 1;i++){
			if(odd[i] > odd[i + 1]){
				flag = 1;
			}
		}
		for(int i = 0;i < k - 1;i++){
			if(even[i] > even[i + 1]){
				flag = 1;
			}
		}
		if(flag){
			cout << "NO" << "\n";
		}else{
			cout << "YES" << "\n";
		}
	}
	
}
